;(function ($) {
	$.extend($.jqValidator,{
		/**---------------------------------------------------------------------------required**/
		//必填规则 初始化
		init_required : function(validateRules){
			var $this = this; 
			var valMsg = validateRules.fieldName==undefined?i18n.message.msgIsNull:validateRules.fieldName+i18n.message.msgIsNull; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{required:{msg:valMsg,show:true}}
					)
				);
		},
		//必填校验
		required : function(validateRules,value){
			var $this = this;
			if(!$.jqValidatorUtils.isEmpty(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).required.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).required.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end required**/
		
		/**---------------------------------------------------------------------------postCode**/
		//postCode规则 初始化
		init_postCode : function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.postCode:validateRules.fieldName+i18n.message.postCode; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{postCode:{msg:valMsg,show:true}}
					)
				);
		},
		//postCode校验
		postCode : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isPostCode(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).postCode.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).postCode.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end postCode**/
		
		/**---------------------------------------------------------------------------email**/
		//email规则 初始化
		init_email : function(validateRules){
			var $this = this; 
			var valMsg = validateRules.fieldName==undefined?i18n.message.email:validateRules.fieldName+i18n.message.email; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{email:{msg:valMsg,show:true}}
					)
				);
		},
		//email校验
		email : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isEmail(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).email.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).email.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end email**/
		

		/**---------------------------------------------------------------------------phoneNumber**/
		//phoneNumber规则 初始化
		init_phoneNumber : function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.phoneText:validateRules.fieldName+i18n.message.phoneText; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{phoneNumber:{msg:valMsg,show:true}}
					)
				);
		},
		//phoneNumber校验
		phoneNumber : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isPhoneNumber(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).phoneNumber.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).phoneNumber.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end phoneNumber**/
		
		/**---------------------------------------------------------------------------number**/
		//number规则 初始化
		init_number : function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.number:validateRules.fieldName+i18n.message.number; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{number:{msg:valMsg,show:true}}
					)
				);
		},
		//number校验
		number : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isNumberText(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).number.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).number.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end number**/
		
		/**---------------------------------------------------------------------------compareNumber**/
		//compareNumber规则 初始化
		init_compareNumber : function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.compareNumber:validateRules.fieldName+i18n.message.compareNumber; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{compareNumber:{msg:valMsg,show:true}}
					)
				);
		},
		//compareNumber校验
		compareNumber : function(validateRules,value){
			var $this = this;
			if(value.length>0 || $.jqValidatorUtils.compareNumber($('#'+validateRules.compareNumber).val(),value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).compareNumber.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).compareNumber.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end compareNumber**/
		
		/**---------------------------------------------------------------------------compareDate**/
		//compareDate规则 初始化
		init_compareDate : function(validateRules){
			var $this = this, compareDate = validateRules.compareDate, start=compareDate.start, end = compareDate.end;
			var valMsg = validateRules.fieldName==undefined?
					i18n.message.greaterThanStartDate:
					validateRules.fieldName+i18n.message.greaterThanStartDate; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{compareDate:{msg:valMsg,show:true}}
					)
				);
			
		},
		//compareDate校验
		compareDate : function(validateRules,value){
			var $this = this;
			var start = validateRules.compareDate.start, end = validateRules.compareDate.end;
			if($.jqValidatorUtils.isEmpty(value) || 
					(($.jqValidatorUtils.isEmpty(start) || $.jqValidatorUtils.compareDate($('#'+ start).val(),value,$this)) && 
						($.jqValidatorUtils.isEmpty(end) || $.jqValidatorUtils.compareDate(value, $('#'+ end).val(),$this)))){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).compareDate.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).compareDate.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end compareDate**/
		
		/**---------------------------------------------------------------------------minLength**/
		//minLength规则 初始化
		init_minLength: function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.minLength:validateRules.fieldName+i18n.message.minLength; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{minLength:{msg:(valMsg).replace("{0}",validateRules.minLength),show:true}}
					)
				);
		},
		//minLength校验
		minLength : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isMinLenth(value,validateRules.minLength)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).minLength.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).minLength.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end minLength**/
		
		/**---------------------------------------------------------------------------maxLength**/
		//maxLength规则 初始化
		init_maxLength: function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.maxLength:validateRules.fieldName+i18n.message.maxLength; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{maxLength:{msg:(valMsg).replace("{0}",validateRules.maxLength),show:true}}
					)
				);
		},
		//maxLength校验
		maxLength : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isMaxLenth(value,validateRules.maxLength)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).maxLength.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).maxLength.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end maxLength**/
		
		/**---------------------------------------------------------------------------minValue**/
		//minValue规则 初始化
		init_minValue : function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.minValue:validateRules.fieldName+i18n.message.minValue; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{minValue:{msg:(valMsg).replace("{0}",validateRules.minValue),show:true}}
					)
				);
		},
		//minValue校验
		minValue : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isMinValue(value,validateRules.minValue)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).minValue.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).minValue.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end minValue**/
		
		/**---------------------------------------------------------------------------maxValue**/
		//maxValue规则 初始化
		init_maxValue: function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.maxValue:validateRules.fieldName+i18n.message.maxValue; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{maxValue:{msg:(valMsg).replace("{0}",validateRules.maxValue),show:true}}
					)
				);
		},
		//maxValue校验
		maxValue : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isMaxValue(value,validateRules.maxValue)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).maxValue.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).maxValue.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end maxValue**/
		

		/**---------------------------------------------------------------------------decimal**/
		//decimal规则 初始化
		init_decimal: function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?i18n.message.decimal:validateRules.fieldName+i18n.message.decimal; 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{decimal:{msg:(valMsg).replace("{0}",validateRules.decimal.intPart).replace("{1}",validateRules.decimal.decimalPart),show:true}}
					)
				);
		},
		//decimal校验
		decimal : function(validateRules,value){
			var $this = this;
			if($.jqValidatorUtils.isEmpty(value)||$.jqValidatorUtils.isRightDecimal(value,validateRules.decimal.intPart,validateRules.decimal.decimalPart)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).decimal.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).decimal.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end decimal**/
		
		/**---------------------------------------------------------------------------customExpression**/
		//customExpression规则 初始化
		init_customExpression: function(validateRules){
			var $this = this;
			var valMsg = validateRules.fieldName==undefined?eval(validateRules.customExpression.message):validateRules.fieldName+eval(validateRules.customExpression.message); 
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{customExpression:{msg:(valMsg),show:true}}
					)
				);
		},
		//customExpression校验
		customExpression : function(validateRules,value){
			var $this = this;
			var reg = eval(validateRules.customExpression.expression);
			if($.jqValidatorUtils.isEmpty(value)|| reg.test(value)){
				//1.验证通过,不显示提示信息
				$this.data($.jqValidator.validateMsgKey).customExpression.show = false;
				return true;
			}else{
				//2.验证不通过,显示提示信息
				$this.data($.jqValidator.validateMsgKey).customExpression.show = true;
				return false;
			}
		},
		/**---------------------------------------------------------------------------end customExpression**/
		
		init_checkAutoSelectValue:function(validateRules){
			var $this = this;
			var valMsg =validateRules.checkAutoSelectValue.message || i18n.message.mustFormSelect;
			$this.data($.jqValidator.validateMsgKey,
					$.extend({},$this.data($.jqValidator.validateMsgKey),
							{checkAutoSelectValue:{msg:(valMsg),show:true}}
					)
				);
		},
		
		checkAutoSelectValue: function(validateRules, value){
			var c = this[0].config;
			if (c.canNotInput === true && !c.isFromSelect && !c.isAjaxDivHide) {
				return false;
			}
			
			return true;
		}
	});
})(jQuery);